package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.AnalysisManageRightRole;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2021-02-24 15:58:39
 */
@Repository
public class AnalysisManageRightRoleDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(AnalysisManageRightRoleDao.class);

    public AnalysisManageRightRole insert(final AnalysisManageRightRole analysisManageRightRole) {
        insert("AnalysisManageRightRole.insert", analysisManageRightRole);
        return analysisManageRightRole;
    }

    public Boolean updateInfoById(final AnalysisManageRightRole analysisManageRightRole) {
        return update("AnalysisManageRightRole.updateInfoById", analysisManageRightRole) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("AnalysisManageRightRole.updateInfoByQuery", query) > 0;
    }

    public AnalysisManageRightRole selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("AnalysisManageRightRole.selectById", query);
    }

    public List<AnalysisManageRightRole> selectByQuery(final Query query) {
        return queryForList("AnalysisManageRightRole.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("AnalysisManageRightRole.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        AnalysisManageRightRole analysisManageRightRole = new AnalysisManageRightRole();
        analysisManageRightRole.setDeleteFlag(1);
        analysisManageRightRole.setId(id);
        analysisManageRightRole.setEntId(entId);

        return update("AnalysisManageRightRole.updateInfoById", analysisManageRightRole) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("AnalysisManageRightRole.deleteById", query) > 0;
    }
}